<!DOCTYPE html>
<html lang="en">

<head>
	<{include file="header.html" }>
	<title>自动排课-排课管理-<{$user_data[ 'school_name']}>-德安信会计在线教育平台</title>
</head>

<body>
	<div class="wrap">
		<!--star left-->
		<div class="column">
			<{include file="left_menu.html" }>
		</div>
		<div id="ContMianBox">
			<!--star子栏目-->
            <div class="sub-colum">
                <div class="tit"><{$left_menu_min.menu}></div>
                <ul>
                    <{foreach from=$left_menu_min.list item=item}>
                    <li <{if $item['url'] == $left_menu_min.curr}>class="curr"<{/if}>><a href="<{$item['url']}>"><{$item['name']}></a></li>
                    <{/foreach}>
                </ul>
            </div>
            <!--end子栏目-->
			<!--end left-->
			<div class="container narrow">
				<!--star conter-->
				<div class="cetContent">

					<!--star内容区域-->
					<div class="mainScroll">
						<div class="tit p-lr20">
							<a class="c-40d064" href="javascript:;">班级排课计划</a><em class="p-lr10 c-CCCCCC fs12">/</em><em>自动排课</em>
						</div>
						<!--star内容区域-->
						<div class="mainScroll">
							<div class="mainContainer line-all" style="min-height:inherit;">
								<dl class="fix">

									<dd>
										<div class="l" style="width:300px;">
											<div class="p-tb5 fs18">
												<{$class_info[ 'class_name']}>
											</div>
											<div class="p-tb5"><span class="c-ff6600">开课时间：<{$class_info[ 'start_time']|date_format: '%Y-%m-%d'}></span></div>
											<div> <span class="">课程名称：<{$class_info[ 'course_name']}></span></div>
											<div class="p-tb5"><span class="">总课时：<{$class_info[ 'class_hour']}></span></div>
											<div class="p-tb5"><span class="">课时时长：<{$class_info[ 'class_hour_time']}>分钟</span></div>
											<div><span class="">上课时间：<{$class_info[ 'class_time']}></span></div>
											<!-- <div>已有<span class="c-ff6600">45</span>人报名</div> -->
											<!-- <div class="p-t5">入班请码：as5144885</div> -->
										</div>
										<div class="l tac" style="width:300px;">
											<button class="layui-btn layui-btn-danger">未开课</button>
											<div class="p-tb20">
												<div class="progressBar m0auto">
													<div class="subBar" style="width:0%"></div>
												</div>
												<div class="p-t5">0%</div>
											</div>
										</div>
									</dd>
								</dl>
							</div>
							<div class="mainContainer line-all">

								<!-- star-->
								<div class="p-t10">

									<div class="mtc_tab">
										<!--star mt-->
										<div class="mt">
											<a href="/classes/detail/<{$class_info[ 'id']}>" >班级学员</a>
											<a href="/classes/plan/<{$class_info[ 'id']}>" class="curr">班级排课</a>
										</div>
										<!--end mt-->

										<!--star mc-->
										<div class="mc">
<form class="layui-form" method="post" style="padding-top:15px;padding-right:30px;">
  <div class="layui-form-item">

      <label class="layui-form-label" style="width: 90px;">开始上课时间</label>
      <div class="layui-input-inline">
        <input type="text" name="class_time" lay-verify="date" placeholder="yyyy-mm-dd" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this, istime: false, format: 'YYYY-MM-DD'})">
      </div>

  </div>
<div class="layui-form-item">
	<fieldset class="layui-form-item layui-elem-field">
		<legend>参数</legend>
		<div class="layui-field-box">

			<div class="layui-form-item" >
			    <label class="layui-form-label" style="width: 90px;">周期</label>
			    <div class="layui-input-inline">
			      <select name="week" id="week" >
			        <option value=""></option>
			        <option value="0" >周日</option>
			        <option value="1" >周一</option>
			        <option value="2" >周二</option>
			        <option value="3" >周三</option>
			        <option value="4" >周四</option>
			        <option value="5" >周五</option>
			        <option value="6" >周六</option>
			        <option value="7" >全周</option>
			      </select>
			    </div>
			    </div>
			<div class="layui-form-item" >
			      <label class="layui-form-label">开始时间</label>

			      <div class="layui-input-inline" style="width:90px;">
			        <select name="hour" id="st_hour" >
			          <option value="">时</option>
			          <option value="8" >8点</option>
			          <option value="9" >9点</option>
			          <option value="10">10点</option>
			          <option value="11">11点</option>
			          <option value="12">12点</option>
			          <option value="13" >13点</option>
			          <option value="14" >14点</option>
			          <option value="15">15点</option>
			          <option value="16">16点</option>
			          <option value="17">17点</option>
			          <option value="18">18点</option>
			          <option value="19">19点</option>
			          <option value="20">20点</option>
			          <option value="21">21点</option>
			          <option value="22">22点</option>

			        </select>
			      </div>
			      <div class="layui-input-inline" style="width:90px;">
			        <select name="minute" id="st_minute">
			          <option value="">分</option>
			          <option value="00" >00</option>
			          <option value="05" >05</option>
			          <option value="10">10</option>
			          <option value="15">15</option>
			          <option value="30">30</option>
			          <option value="45">45</option>
			        </select>
			      </div>
			    </div>
			    <div class="layui-form-item" >
			      <label class="layui-form-label">结束时间</label>

			      <div class="layui-input-inline" style="width:90px;">
			        <select name="hour" id="en_hour" >
			          <option value="">时</option>
			          <option value="8" >8点</option>
			          <option value="9" >9点</option>
			          <option value="10">10点</option>
			          <option value="11">11点</option>
			          <option value="12">12点</option>
			          <option value="13" >13点</option>
			          <option value="14" >14点</option>
			          <option value="15">15点</option>
			          <option value="16">16点</option>
			          <option value="17">17点</option>
			          <option value="18">18点</option>
			          <option value="19">19点</option>
			          <option value="20">20点</option>
			          <option value="21">21点</option>
			          <option value="22">22点</option>

			        </select>
			      </div>
			      <div class="layui-input-inline" style="width:90px;">
			        <select name="minute" id="en_minute" >
			          <option value="">分</option>
			          <option value="00" >00</option>
			          <option value="05" >05</option>
			          <option value="10">10</option>
			          <option value="15">15</option>
			          <option value="30">30</option>
			          <option value="45">45</option>
			        </select>
			      </div>
			    </div>

			    <div class="layui-form-item">
					<label class="layui-form-label"></label>
					<div class="layui-inline">

						<a class="layui-btn" href="javascript:;" id="add_args"><i class="layui-icon"></i> 添加排课参数</a>
					</div>
				</div>
		</div>
	</fieldset>
</div>
<div class="layui-form-item">
	<fieldset class="layui-form-item layui-elem-field">
		<legend>参数</legend>
		<div class="layui-field-box" id="args_list">

		</div>
	</fieldset>
</div>




  <div class="layui-form-item">
    <label class="layui-form-label">讲师</label>
    <div class="layui-input-inline">
      <select name="teacher_id" lay-verify="required">
        <option value=""></option>
        <{foreach from=$teachers item=item}>
        <option value="<{$item['id']}>" <{if $class_info['lecturer_id']==$item['id'] }>selected<{/if}> ><{$item['teacher_name']}></option>
        <{/foreach}>
      </select>
    </div>
  </div>
<div class="layui-form-item">
    <label class="layui-form-label">教室</label>
    <div class="layui-input-inline">
      <select name="class_room" lay-verify="required">
        <option value=""></option>
        <{foreach from=$room_list item=item}>
        <option value="<{$item['id']}>" <{if $class_info['classroom']==$item['id'] }>selected<{/if}>><{$item['name']}></option>
        <{/foreach}>
      </select>
    </div>
  </div>


  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit="" lay-filter="*" >开始排课</button>
      <!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button> -->

    </div>
  </div>
</form>

										</div>
										<!--end mc-->
									</div>

								</div>
								<!-- end -->

							</div>
						</div>
					</div>
					<!--end内容区域-->

					<!--end conter-->
				</div>


			</div>
		</div>
<{include file="footer.html"}>
<script>
layui.use('form', function(){
  	var form = layui.form();
	form.on('submit(*)', function(data){
	  console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
	  console.log(data.form) //被执行提交的form对象，一般在存在form标签时才会返回
	  console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
	  var args = $("input[name='args[]']").val();
  		if(args == undefined ){
  			alert("请添加上课时间段");
	  		return false;
  		}

  		 //阻止表单跳转。如果需要表单跳转，去掉这段即可。
	});

  //各种基于事件的操作，下面会有进一步介绍
});
</script>
<script>
	var iframe_index ;
	$(function () {
		// $(".delete_data").on("click",function () {
		// 	$(this).parent().remove();
		// });

		$("#add_args").click(function(){
			var week = $("#week").val();
			var week_name = $('#week option:selected').text();
			if(week==""){
				alert('请选择周期');
				return;
			}

			var st_hour = $("#st_hour").val();
			var st_minute = $("#st_minute").val();

			if(st_hour==""){
				alert('请选择开始时间');
				return;
			}
			if(st_minute==""){
				alert('请选择开始分钟');
				return;
			}

			var en_hour = $("#en_hour").val();
			var en_minute = $("#en_minute").val();

			if(en_hour==""){
				alert('请选择结束时间');
				return;
			}
			if(en_minute==""){
				alert('请选择结束分钟');
				return;
			}
			//计算时长
			var h = en_hour - st_hour;
			var m = en_minute - st_minute;
			if(h<0){
				alert('请选择正确的时间段');
				return;
			}
			if (h==0 && m<=0){
				alert('请选择正确的时间段');
				return;
			}
			var total = h*60 + m;
			var te = <{$class_info[ 'class_hour_time']}>;
			if(total<te){
				alert('请选择正确的时间段');
				return;
			}



			var sjd = st_hour+':'+st_minute+'-'+en_hour+':'+en_minute;
			var start_time = st_hour+':'+st_minute;
			var end_time = en_hour+':'+en_minute;
			var val = '{"week":'+week+',"start_time":"'+start_time+'","end_time":"'+end_time+'","hour_time":'+parseInt(total/te)+',"total_time":'+total+'}';

			var html = '<div class="layui-form-item" ><label class="layui-form-label" style="width: 450px;">周期：'+week_name+' 时间段：'+sjd+'时长：'+( h*60 + m)+'分钟   课时：'+parseInt(total/te)+'</label><input type="hidden" name="args[]" value=\''+val+'\'><a class="layui-btn layui-btn-primary layui-btn-small delete_data" href="javascript:;" onclick="javascript: $(this).parent().remove();"><i class="layui-icon"></i></a></div>';

			$("#args_list").append(html);

		})
	});
</script>

</body>

</html>
